package com.day04_string_test;

/**
 * @ClassName: StringTest01
 * @Author: 豆豆在睡觉
 * @Create 2024/2/25-17:07
 * @Version 1.0
 */
public class StringTest01 {
    // 字符串构造


    public static void main(String[] args) {
        char[] chs = {'a', 'b', 'c'};
        String s = new String(chs);
        System.out.println(s);

        byte[] bys = {97,98,100};
        String ss = new String(bys);
        System.out.println(ss);

        // 字符串比较
        char[] chs1 = {'a', 'b', 'c'};
        char[] chs2 = {'a', 'b', 'c'};
        String s1 = new String(chs1);
        String s2 = new String(chs2);

        // 首先通过 == 比较
        if (s1 == s2) {
            System.out.println("s1 == s2");
        } else {
            System.out.println("s1 != s2");
        }

        // 其次通过equals 比较
        if (s1.equals(s2)) {
            System.out.println("s1和s2内容相同");
        } else {
            System.out.println("s1和s2内容不同");
        }
    }
}
